home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / blitzbasic / blitz-list200994.lha / blitz-list / text0223.txt < prev    next >
Encoding:
Text File  |  1994-09-20  |  2.2 KB  |  86 lines

  1. Here we go, the Copper disassembler.
  2.  
  3. Dim clist.w(500,1) ;set up an array to hold the Coplist
  4.                    ;500 instructions should certainly be enough
  5.  
  6. BLITZ
  7.  
  8. ;Set up all slices/displays and CustomCops/Colsplits here, as you would
  9. ;use them in your game
  10.  
  11. gosub C_store; stores contents of Copper List in array
  12.  
  13. AMIGA
  14.  
  15. ;Set up a screen (I leave this to you)
  16. ;and have a look at it
  17.  
  18. gosub C_disasm; interprets and prints out
  19.  
  20. End
  21.  
  22. .C_store
  23. numcop=0
  24. For i=0 to CopLen step 4
  25.  adr.l=CopLoc+i
  26.  clist(numcop,0)=Peek.w(adr):clist(numcop,1)=Peek.w(adr+2)
  27.  numcop+1
  28. Next
  29. Return
  30.  
  31. Function h${i}
  32. Function Return Left$(4,hex$(i))
  33. End Function
  34.  
  35. .C_disasm
  36. For i=0 to numcop-1
  37.  If clist(i,0)&1=0;Move Instruction
  38.   DA=clist(i,0)&511
  39.   RD=clist(i,1)
  40.   Nprint i*4," Move ",h{DA}," #"h{RD}
  41.  Else;Wait or Skip Instruction
  42.   VP=clist(i,0)ASR8:HP=(clist(i,0)&254)ASL1
  43.   VE=(clist(i,1)ASR8)&127:HP=(clist(i,1)&254)ASL1
  44.   If clist(i,1)&1=0;Wait Instruction
  45.    Nprint i*4," Wait(",HP,",",VP,")("HE,",",VE,")"
  46.   Else
  47.    NPrint i*4," Skip(",HP,",",VP,")("HE,",",VE,")"
  48.   Endif
  49.  Endif
  50. Next
  51.  
  52. And there we have it. I'd check the h Function - it is intended to give
  53. neat hex output
  54.  
  55. Anyway, the output looks something like
  56.  
  57. 0 Wait(0,44)(255,255)
  58. 4 Move 180 #fff
  59. etc.
  60.  
  61. The Wait means that the Copper waits until the video beam reaches the
  62. coordinates (0,44) after being logically AND ed with the mask (255,255)
  63. It then Pokes he value fff into the Register $180 (which I believe is
  64. the address for Colour 0 on the ECS chipset.
  65.  
  66. To change the data being poked in Poke the new word into the address 
  67. CopLoc+4(figure on left of disasm output)+2(1 word)
  68.  
  69. i.e. Poke.w CopLoc+6,$ff0 would change Colour 0 to Yellow.
  70.  
  71. The typical Copper list will have a Wait at the top of each Slice, then
  72. a lot of Pokes into the Colour Table, Sprite Registers and BPLMods and
  73. so on, all of which are listed in the back of the Blitz manual.
  74. To change the Y value for waits, Poke the new y as a byte  into the
  75. address given by CopLoc+number on left. This can be used to e.g. move a
  76. ColSplit up and down the screen, but make sure that all waits are still
  77. in strict numerical order of y values. 
  78.  
  79.            Happy Poking
  80.                 Mike Cooper
  81.   
  82.  
  83.  
  84.  
  85.  
  86.